<% layout('testboilerplate') -%>
<link rel="stylesheet" href="/lib/yduiCity/ydui.css" />
<link rel="stylesheet" href="<%= linkPath %>/css/test.css" />
<link rel="stylesheet" href="<%= linkPath %>/css/sliderRule.css" />
<link rel="stylesheet" href="<%= linkPath %>/css/testresponsive.css" />
<script type="text/javascript" src="/lib/yduiCity/ydui.flexible.js"></script>
<script type="text/javascript" src="/lib/yduiCity/ydui.citys.js"></script>
<script type="text/javascript" src="/lib/yduiCity/ydui.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src="/lib/in01.js"></script>
<!--<script src="//cdn.jsdelivr.net/npm/eruda"></script>-->
<!--<script>eruda.init();</script>-->


<div class="index-wrapper" style="background-color:#ffb8c0">
    <!--asdasdasdasd-->
   <div class="container-fluid" style="height: 100%">
       <div class="row index-bac">
           <div class="index-content" style=" background-image: url('<%= linkPath %>/images/test/bac_point.png');padding: 24px 15px;">

               <div class="page pageSection" data-page='#page1'>
                    <div class="ques-section">

                    </div>
               </div>

               <div class="pageSection hide" data-page="#page2">
                   <input type="hidden" name="2" value="">
                   <div class="ques-section multi">
                       <p class="title">爸妈备孕难题（多选）</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="21" class="specical ansText noQues">正常</span></div>
                           <div class="col-xs-6"><span data-val="22" class="ansText">男方问题</span></div>
                           <div class="col-xs-6"><span data-val="23" class="ansText">子宫问题</span></div>
                           <div class="col-xs-6"><span data-val="24" class="ansText">卵巢问题</span></div>
                           <div class="col-xs-6"><span data-val="25" class="ansText">染色体异常</span></div>
                           <div class="col-xs-6"><span data-val="26" class="ansText">输卵管问题</span></div>
                           <div class="col-xs-6"><span data-val="27" class="ansText">免疫性不孕</span></div>
                           <div class="col-xs-6"><span data-val="28" class="ansText">不明原因</span></div>
                           <div class="col-xs-6"><span data-val="29" class="ansText">我不清楚</span></div>
                           <div class="col-xs-6"><span class="ansText noQues">其他问题</span></div>
                       </div>
                       <div class="cus_input hide">
                           <input type="text" placeholder="请输入" >
                       </div>
                       <div class="cus_tip hide">
                           <p>为了让您更全面的了解自己生育能力，
                               建议您去<span class="markColor">专业的机构</span>进行<span class="markColor">孕前体检</span></p>
                       </div>
                   </div>
               </div>
               <div class="pageSection hide" data-page="#page3">
                   <input type="hidden" name="3" value="">
                   <div class="ques-section multi">
                       <p class="title">准爸爸精子情况（多选）</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="31" class="ansText noQues">正常</span></div>
                           <div class="col-xs-6"><span data-val="32" class="ansText">少精/弱精</span></div>
                           <div class="col-xs-6"><span data-val="33" class="ansText">无精</span></div>
                           <div class="col-xs-6"><span data-val="34" class="ansText">死精</span></div>
                           <div class="col-xs-6"><span data-val="35" class="ansText">高畸形</span></div>
                           <div class="col-xs-6"><span data-val="36" class="ansText">我不清楚</span></div>
                       </div>
                       <div class="cus_tip hide">
                           <p>想要了解准爸爸的生育能力，可以去
                               进行<span class="markColor">精液常规</span>、<span class="markColor">精子形态</span>等检查哦</p>
                       </div>
                   </div>
               </div>
               <div class="pageSection hide" data-page="#page4">
                   <input type="hidden" name="4" value="">
                   <div class="ques-section multi">
                       <p class="title">准妈妈子宫情况（多选）</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="41" class="ansText">正常</span></div>
                           <div class="col-xs-6"><span data-val="42" class="ansText">子宫内膜异位</span></div>
                           <div class="col-xs-6"><span data-val="43" class="ansText">子宫肌瘤</span></div>
                           <div class="col-xs-6"><span data-val="44" class="ansText">子宫内膜菲薄</span></div>
                           <div class="col-xs-6"><span data-val="45" class="ansText">子宫肌腺症</span></div>
                           <div class="col-xs-6"><span data-val="46" class="ansText">我不清楚</span></div>
                           <div class="col-xs-6"><span class="ansText">其他问题</span></div>
                       </div>
                       <div class="cus_input hide">
                           <input type="text" placeholder="请输入" >
                       </div>
                       <div class="cus_tip hide">
                           <p>想要了解准妈妈的子宫情况，可以
                               去进行<span class="markColor">B超、宫腔镜、腹腔镜、子宫腔造影</span>等检查哦~</p>
                       </div>
                   </div>
               </div>
               <div class="pageSection hide" data-page="#page5">
                   <input type="hidden" name="5" value="">
                   <div class="ques-section multi">
                       <p class="title">准妈妈卵巢情况（多选）</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="51" class="ansText">正常</span></div>
                           <div class="col-xs-6"><span data-val="52" class="ansText">卵巢储备下降</span></div>
                           <div class="col-xs-6"><span data-val="53" class="ansText">卵巢早衰/功能差</span></div>
                           <div class="col-xs-6"><span data-val="54" class="ansText">多囊卵巢</span></div>
                           <div class="col-xs-6"><span data-val="55" class="ansText">卵泡发育缓慢</span></div>
                           <div class="col-xs-6"><span data-val="56" class="ansText">巧克力囊肿</span></div>
                           <div class="col-xs-6"><span data-val="57" class="ansText">我不清楚</span></div>
                           <div class="col-xs-6"><span class="ansText">其他问题</span></div>
                       </div>
                       <div class="cus_input hide">
                           <input type="text" placeholder="请输入" >
                       </div>
                       <div class="cus_tip hide">
                           <p>想要了解准妈妈的卵巢情况，可以去进行<span class="markColor">性
                               激素六项、B超、腹腔镜</span>等检查哦~</p>
                       </div>
                   </div>
               </div>
               <div class="pageSection hide" data-page="#page6">
                   <input type="hidden" name="10" value="">
                   <div class="ques-section multi">
                       <p class="title">输卵管情况（多选）</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="101" class="ansText">正常</span></div>
                           <div class="col-xs-6"><span data-val="102" class="ansText">输卵管积水</span></div>
                           <div class="col-xs-6"><span data-val="103" class="ansText">输卵管结扎</span></div>
                           <div class="col-xs-6"><span data-val="104" class="ansText">我不清楚</span></div>
                           <div class="col-xs-6"><span class="ansText">其他问题</span></div>
                       </div>
                       <div class="cus_input hide">
                           <input type="text" placeholder="请输入" >
                       </div>
                       <div class="cus_tip hide">
                           <p>想要了解准妈妈的输卵管情况，可以去进行<span class="markColor">性腹
                               腔镜、B超、输卵管造影</span>等检查哦~</p>
                       </div>
                   </div>
               </div>
               <div class="pageSection singlePage hide" data-page="#page7">
                   <input type="hidden" name="6" value="">
                   <div class="ques-section single">
                       <p class="title" data-name="61">准妈妈曾经怀孕过多少次？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="611" class="ansText">0</span></div>
                           <div class="col-xs-4"><span data-val="612" class="ansText">1</span></div>
                           <div class="col-xs-4"><span data-val="613" class="ansText">2</span></div>
                           <div class="col-xs-4"><span data-val="614" class="ansText">3</span></div>
                           <div class="col-xs-4"><span data-val="615" class="ansText">4次以上</span></div>
                       </div>
                   </div>
                   <div class="ques-section single">
                       <p class="title" data-name="62">曾经生过多少宝宝?</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="621" class="ansText">0</span></div>
                           <div class="col-xs-4"><span data-val="622" class="ansText">1</span></div>
                           <div class="col-xs-4"><span data-val="623" class="ansText">2</span></div>
                           <div class="col-xs-4"><span data-val="624" class="ansText">3</span></div>
                           <div class="col-xs-4"><span data-val="625" class="ansText">4次以上</span></div>
                       </div>
                   </div>
                   <div class="ques-section single">
                       <p class="title" data-name="63">已经尝试过多少次试管?</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="631" class="ansText">0</span></div>
                           <div class="col-xs-4"><span data-val="632" class="ansText">1</span></div>
                           <div class="col-xs-4"><span data-val="633" class="ansText">2</span></div>
                           <div class="col-xs-4"><span data-val="634" class="ansText">3</span></div>
                           <div class="col-xs-4"><span data-val="635" class="ansText">4次以上</span></div>
                       </div>
                   </div>
               </div>
               <div class="pageSection singlePage hide" data-page="#page8">
                   <input type="hidden" name="7" value="">
                   <div class="ques-section single">
                       <p class="title" data-name="71">医生末次为你们拟定的试管类型是?</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6"><span data-val="711" class="ansText">第一代试管婴⼉</span></div>
                           <div class="col-xs-6"><span data-val="712" class="ansText">第二代试管婴⼉</span></div>
                           <div class="col-xs-6"><span data-val="713" class="ansText">第三代试管婴⼉</span></div>
                           <div class="col-xs-6"><span data-val="714" class="ansText">我不清楚</span></div>
                       </div>
                   </div>
                   <div class="ques-section single">
                       <p class="title" data-name="72">医生末次为你们拟定的促排方案是？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="721" class="ansText">长方案</span></div>
                           <div class="col-xs-4"><span data-val="722" class="ansText">短方案</span></div>
                           <div class="col-xs-4"><span data-val="723" class="ansText">超长方案</span></div>
                           <div class="col-xs-4"><span data-val="724" class="ansText">拮抗剂方案</span></div>
                           <div class="col-xs-4"><span data-val="725" class="ansText">微刺激方案</span></div>
                           <div class="col-xs-4"><span data-val="726" class="ansText">自然周期</span></div>
                           <div class="col-xs-4"><span data-val="727" class="ansText">我不清楚</span></div>
                       </div>
                   </div>
               </div>
               <div class="pageSection singlePage hide" data-page="#page9">
                   <input type="hidden" name="8" value="">
                   <div class="ques-section unclude">
                       <p class="title" data-name="81">您所在地区？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4">
                               <input type="text" class="cell-input" readonly id="J_Address" placeholder="所在地区">
                           </div>
                       </div>
                   </div>
                   <div class="ques-section single">
                       <p class="title" data-name="82">您是否有意愿尝试试管婴儿助孕？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="821" class="ansText isSure">有意愿</span></div>
                           <div class="col-xs-4"><span data-val="822" class="ansText isSure">没有意愿</span></div>
                           <div class="col-xs-4"><span data-val="823" class="ansText isSure">考虑中</span></div>
                       </div>
                   </div>
                   <div class="ques-section single sureOption hide">
                       <p class="title" data-name="83">您希望进行试管婴儿的城市？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-4"><span data-val="831" class="ansText">省内</span></div>
                           <div class="col-xs-4"><span data-val="832" class="ansText">国内</span></div>
                           <div class="col-xs-4"><span data-val="833" class="ansText">海外</span></div>
                       </div>
                   </div>
                   <div class="ques-section single sureOption hide">
                       <p class="title" data-name="84">您的试管婴儿预算？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6 col-md-4"><span data-val="841" class="ansText">5万以下</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="842" class="ansText">10万以下</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="843" class="ansText">20万以下</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="844" class="ansText">30万以下</span></div>
                           <div class="col-xs-12 col-md-4"><span data-val="845" class="ansText">只要能怀上,钱不是问题</span></div>
                       </div>
                   </div>
               </div>
               <div class="pageSection hide" data-page="#page10">
                   <input type="hidden" name="9" value="">
                   <div class="ques-section multi">
                       <p class="title">您有哪些特别需求？</p>
                       <div class="ans-cont clearfix">
                           <div class="col-xs-6 col-md-4"><span data-val="91" class="ansText">都没有</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="92" class="ansText">基因筛查</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="93" class="ansText">供精/供卵</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="94" class="ansText">男女选择</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="95" class="ansText">合法代孕</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="96" class="ansText">海外技术</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="97" class="ansText">高端服务</span></div>
                           <div class="col-xs-6 col-md-4"><span data-val="98" class="ansText">经济服务</span></div>
                           <div class="col-xs-6 col-md-4"><span class="ansText">其他</span></div>
                       </div>
                       <div class="cus_input hide">
                           <input type="text" placeholder="请输入" >
                       </div>
                   </div>
               </div>
               <div class="pageSection telPage hide" data-page="#page11">
                   <input type="hidden" name="tel" value="">
                   <div class="ques-section">
                       <p class="title">试管助手成功率的算法基于真实用户的大数据信息，为防止虚假数据干扰准确性，请输入手机号码以确保用户信息的真实性:</p>
                       <div class="ans-cont">
                           <input class="tel-input" onkeyup="value=value.replace(/[^\d]/g,'')" type="text" placeholder="请输入您的手机号码" >
                       </div>
                   </div>

               </div>

           </div>
           <div class="text-center ans-footer">
               <span><img src="<%= linkPath %>/images/test/next.png" alt="下一步"></span>
           </div>
       </div>
   </div>
</div>
<script>
    $(function () {
        var isPC = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);
        var $winWidth = $(window).width();
        $('body').height($('body')[0].clientHeight); //防止软键盘挤压高度

        $.get('<%= baseUrl %>/testing/ticket',{page:encodeURIComponent(location.href.split("#")[0])},function (data) {
            var t = JSON.parse(data.t)
            wx.config({
                debug: '<%= isWxdebug %>'=='false'?false:true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: t.appid , // 必填，公众号的唯一标识
                timestamp: t.timestamp, // 必填，生成签名的时间戳
                nonceStr: t.noncestr , // 必填，生成签名的随机串
                signature: t.signature ,// 必填，签名，见附录1
                jsApiList: ['checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage' ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            })

            wx.ready(function () {

                wx.checkJsApi({
                    jsApiList: [
                        'onMenuShareTimeline',
                        'onMenuShareAppMessage'
                    ],
                    success: function (res) {
                        // alert(JSON.stringify(res));
                    },
                    error:function (err) {
                        alert('您的微信版本不支持自定义分享，请下载或更新最新版本');
                    }
                });

                wx.onMenuShareTimeline({
                    title: '<%= wxtitle %>', // 分享标题
                    link: '<%= baseUrl %>/testing', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: '<%= baseUrl %>/images/test/pc_bac.jpg', // 分享图标
                    success: function () {
                        // 用户确认分享后执行的回调函数
                        // alert("分享给朋友圈成功")
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

                //记录坑: 下面的link 和 签名用的url  都要加上 http 才能继续往下分享
                wx.onMenuShareAppMessage({
                    title: '<%= wxtitle %>', // 分享标题
                    desc: '<%= wxdesc %>', // 分享描述
                    link: '<%= baseUrl %>/testing', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: '<%= baseUrl %>/images/test/pc_bac.jpg', // 分享图标
                    type: 'link', // 分享类型,music、video或link，不填默认为link
                    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                    success: function () {
                        // alert("分享给朋友成功")
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // alert("分享给朋友失败")
                        // 用户取消分享后执行的回调函数
                    }
                });
            })

            wx.error(function (res) {
                alert("error: " + res.errMsg);
            });
        })


        var getNumLi = function (min,max,range) {
            var str = '';
            var range = range || 1
            for(var i = min;i<=max;i+=range){
                str += '<li><span class="num">'+ i +'</span></li>'
            }
            return str;
        }

        if($winWidth < 767){
            $('.index-bac').css(
                {'background':'url("/images/test/phone_ans_bac.jpg") no-repeat top center',
                    "background-size":"cover"})
        }

        // if(!sessionStorage.getItem('rate')){
        //     location.href = location.origin + "/testing"
        //     sessionStorage.setItem('rate','0')
        // }


        //初始化地址选择
        var $target = $('#J_Address');

        $target.citySelect();

        $target.on('click', function (event) {
            event.stopPropagation();
            $target.citySelect('open');
        });

        $target.on('done.ydui.cityselect', function (ret) {
            $(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
        });


        $('.page .ques-section').append(`<div class="page-main">
                       <input type="hidden" name="1" value="30##150##50">
                       <div class="row">
                           <label for="" class="label">您的年龄 <span class="number age-num" initial-value="12" value="30">30</span><span class="letter">岁</span></label>
                           <div class="ruler ruler-age">
                               <div class="main" value="-1">
                                   <ul data-initial='true'>
                                       ${getNumLi(18,50)}
                                   </ul>
                               </div>
                               <div class="arrow"></div>
                           </div>
                       </div>

                       <div class="row">
                           <label for="" class="label">您的身高 <span class="number height-num" initial-value="10" value="150">150</span><span class="letter">cm</span></label>
                           <div class="ruler ruler-height">
                               <div class="main" value="-1">
                                   <ul data-initial='true'>
                                       ${getNumLi(140,200,10)}
                                   </ul>
                               </div>
                               <div class="arrow"></div>
                           </div>
                       </div>

                       <div class="row">
                           <label for="" class="label">您的体重 <span class="number width-num" initial-value="8" value="50">50</span><span class="letter">kg</span></label>
                           <div class="ruler ruler-weight">
                               <div class="main" value="0">
                                   <ul data-initial='true'>
                                       ${getNumLi(30,100,5)}
                                   </ul>
                               </div>
                               <div class="arrow"></div>
                           </div>
                       </div>
                   </div>`)
        var showHideHash = function () {
            var hash = location.hash || '#page1';
            if(hash == '#page11'){
                $(".ans-footer img").attr("src","<%= linkPath%>/images/test/test_start.png");
            }else{
                $(".ans-footer img").attr("src","<%= linkPath%>/images/test/next.png");
            }
            if(hash){
                $('[data-page]').addClass('hide');
                $('[data-page="'+ hash +'"]').removeClass('hide')
            }else {
                toHashPage('#page1');
            }

        }

        var toHashPage = function (page) {
            location.href = location.origin + "/testing/index"+page
        }
        //复选页  检查是否有选项
        var isChose = function () {
            var $tempDom = $(".ques-section:visible").find('.ansText.active');
            var $tempInput = $(".ques-section:visible").find(".cus_input > input");
            if($tempDom.length){
                if($tempInput.length && $tempInput.is(':visible') && $tempInput.val() == ""){
                    return false;
                }
                return true
            }
            return false
        }
        //单选页 检查
        var isSingleChose = function () {
            var flag = true;
            var $cont = $(".pageSection:visible");
            var pageNum = $cont.data("page");
            if(pageNum == '#page9'){
                if($("#J_Address").val() == ''){
                    flag = false;
                }
            }
            $cont.find(".ques-section:visible").not(".unclude").each(function (i,v) {
                var $temp = $(v).find(".ans-cont .ansText.active");
                if(!$temp.length){
                    flag = false;
                }
            })
            return flag;
        }

        //获取单选页答案
        var getSingleQuestion = function (dom) {
            var temp = {};
            var quesSection = dom.find(".ques-section:visible");
            quesSection.each(function (i,v) {
                var key =  $(v).find("p").data('name');
                var value = $(v).find("#J_Address").length ? $("#J_Address").val().split(" ").join("/") : $(v).find('.ans-cont .ansText.active').data('val');
                temp[key] = value;
            })
            return JSON.stringify(temp);
        }
        //获取复选页答案
        var getThisQuestion = function (dom) {
            var ques = [];
            var $tempDom = dom.find('.ansText.active');
            var $input = dom.find('.cus_input > input');
            if(!$tempDom.length) return
            dom.find('.ansText.active').not('.noQues').each(function (i,v) {
                ques.push($(v).data('val'));
            })
            if($input.length && $input.is(':visible') && $input.val() != ''){
                ques.push($input.val())
            }
            return ques.join("##");
        }

        //获取最后答案
        var getResultData = function () {
            var obj = {};
            var $pageDom = $(".pageSection").not(".telPage").not('.singlePage');
            var $singlePageDom = $(".singlePage");
            $pageDom.each(function () {
                var $input = $(this).find("input[type=hidden]");
                if($input.val() != ''){
                    obj[$input.attr('name')] = $input.val().split("##");
                }
            })
            $singlePageDom.each(function () {
                var $input = $(this).children("input[type=hidden]");
                if($input.val() != ''){
                    obj[$input.attr('name')] = JSON.parse($input.val());
                }
            })

            obj['tel'] = $('.tel-input').val();

            return obj
        }

        //base64 转
        var base64Encode = function (input){
            var rv;
            rv = encodeURIComponent(input);
            rv = unescape(rv);
            rv = window.btoa(rv);
            return rv;
        }

        showHideHash();

        $(window).on('hashchange',function () {
            showHideHash();
        })


        window.pageQueue = [];
        //下一步跳转
        $(document).on('click','.ans-footer span',function () {
            var $curQuesSection = $(".pageSection:visible");
            var $pageNum = $curQuesSection.data("page");
            var curQues = getThisQuestion($curQuesSection.find(".ques-section"));
            var num  = $pageNum.split("e")[1];

            if(num >= 2 && num < 7 || num == 10){  //都是复选
                if(!isChose()){  // 复选情况下没有进行选择
                    alert('请选择后再继续下一步')
                    return
                }
                if($pageNum == "#page2"){
                    if(!curQues && $(".specical.active")){
                        toHashPage("#page7");
                        $(".specical").closest(".pageSection").find("input[type=hidden]").val('没有')
                        return
                    }
                    pageQueue = [];
                    if(curQues.indexOf("22") > -1){
                        pageQueue.push("#page3")
                    }
                    if(curQues.indexOf("23") > -1){
                        pageQueue.push("#page4")
                    }
                    if(curQues.indexOf("24") > -1){
                        pageQueue.push("#page5")
                    }
                    if(curQues.indexOf("26") > -1){
                        pageQueue.push("#page6")
                    }
                }
                $curQuesSection.find('input[type=hidden]').val(curQues);
            }else if($pageNum != "#page1"){
                if($pageNum != "#page11"){
                    if(!isSingleChose()){
                        alert('请选择后再继续下一步')
                        return
                    }
                    $curQuesSection.find('input[type=hidden]').val(getSingleQuestion($curQuesSection));
                }else  {
                    if($(".tel-input").val() == '' || $(".tel-input").val().length != 11){
                        alert('请填写手机号后开始测试')
                        return
                    }
                    $("[data-page='#page11']").find("input[type=hidden]").val($(".tel-input").val());
                }
            }


            if(num >= 6 && num <= 10){
                toHashPage("#page"+ ($pageNum.split("e")[1]*1 + 1))
            }else if(num >= 2 && num < 6){
                if(num != 2){
                    var curNumIndex = pageQueue.findIndex(function (v) {
                        return v == $pageNum;
                    })   //去找队列里的
                    if(curNumIndex != -1){
                        if(!!pageQueue[curNumIndex+1]){
                            toHashPage(pageQueue[curNumIndex+1]) //当前还有
                        }else{
                            toHashPage("#page7")
                        }
                    }else {
                        toHashPage("#page7")
                    }
                }else {
                    pageQueue.length ?  toHashPage(pageQueue[0]) : toHashPage("#page7");
                }
            }else if(num == 1){
                toHashPage("#page2")
            }else if(num == 11){
                var base64str = base64Encode(JSON.stringify(getResultData()));
                $.post('http://www.songbaochina.com:8000/tube_baby',{aaa:base64str},function (data) {
                    var data = JSON.parse(data);

                    if(data.error == 1){
                        var rate = (data.rate * 100).toFixed(2);
                        location.href = location.origin + '/testing/result?rate='+rate;
                        // if(sessionStorage.getItem('rate')){
                        //     sessionStorage.removeItem("rate")
                        // }
                        // sessionStorage.setItem('rate',rate);

                    }
                })
            }

        })

        //单选题点击事件
        $(document).on("click",".single .ans-cont span.ansText",function () {
            $(this).addClass("active").parent().siblings().children().removeClass("active");
        })

        //是否有意愿的点击事件
        $(document).on("click",".isSure",function () {
            var isActive = $(this).text();
            var $sureOption = $(this).closest(".pageSection").find('.sureOption');
            isActive != '没有意愿' ? $sureOption.removeClass("hide") : $sureOption.addClass("hide");
        })

        //复选题点击事件
        $(document).on('click',".multi .ans-cont span.ansText",function () {
            var thisText = $(this).text();
            var thisIndex = $(this).parent().index();
            var $cont = $(this).closest('.ques-section');
            if(thisIndex != $(this).parents('.ans-cont').children().length - 1){ //如果点击的不是最后一个
                if(thisIndex == 0 || thisText == '没有' || thisText == '正常'){
                    $cont.find("span.ansText").removeClass('active');
                    $cont.find('.cus_input').addClass('hide');
                }else {
                    $cont.find("span.ansText").eq(0).removeClass('active');
                }
            }else {
                $cont.find('.cus_input').toggleClass('hide');
                $cont.find("span.ansText").eq(0).removeClass('active')
            }
            $(this).toggleClass('active');

            if(thisText == '我不清楚'){
                $cont.find('.cus_tip').removeClass('hide');
            }
        })


        //禁止输入特殊字符
        function showKeyPress(evt) {
            evt = (evt) ? evt : window.event
            return checkSpecificKey(evt.keyCode);
        }

        function checkSpecificKey(keyCode) {
            var specialKey = "[`~#@$^&*()=|{}\\[\\]~#￥……&*（）——|{}【】]";//Specific Key list
            var realkey = String.fromCharCode(keyCode);
            var flg = false;
            flg = (specialKey.indexOf(realkey) >= 0);
            if (flg) {
                // alert('请勿输入特殊字符: ' + realkey);
                return false;
            }
            return true;
        }
        document.onkeypress = showKeyPress;
    })
</script>
